package com.woniuxy.Service.Impl;

import com.woniuxy.Service.IUserService;
import com.woniuxy.dao.UserMapper;
import com.woniuxy.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.valueextraction.UnwrapByDefault;
import java.util.List;

/**
 * @author lg
 * @time 2020/07/09 19:33:40
 */
 @Service
 @Transactional  // 事务
public class IUserServiceImpl implements IUserService {

     @Autowired
     private UserMapper userMapper;

    @Override
    public void save(User user) {
          userMapper.insert (user);
    }

    @Override
    public void delete(Integer uid) {
           userMapper.deleteByPrimaryKey (uid);
    }

    @Override
    public void update(User user) {
      userMapper.updateByPrimaryKey (user);
    }

    @Override
    public User find(Integer uid) {

        return  userMapper.selectByPrimaryKey (uid);
    }

    @Override
    public List<User> find() {

        return  userMapper.selectByExample (null);
    }
}
